<!DOCTYPE html>
<html lang="zh-cn">
  <head>
    <meta charset="utf-8">
    <title>呼叫中心运营平台</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" type="text/css" href="/css/bootstrap.min.css">
    <link rel="stylesheet" type="text/css" href="/css/non-responsive.css">
    <link rel="stylesheet" type="text/css" href="/css/bootstrap-theme.css">
    <link rel="stylesheet" type="text/css" href="/css/global.css">
    <link rel="stylesheet" type="text/css" href="/css/company.css">
  </head>
  <body>
    <nav class="navbar navbar-inverse navbar-static-top">
      <div class="container">
        <div class="navbar-header">
          <a class="navbar-brand" href="#"><img alt="Logo" src="/img/logo.png"></a>
          <a class="navbar-brand" href="#">运营平台</a>
        </div>
        <div id="navbar">
          <ul class="nav navbar-nav">
            <li><a href="/company">企业管理</a></li>
            <li><a href="/task">任务监控</a></li>
            <li><a href="/user">账户管理</a></li>
            <li><a href="/agent">座席管理</a></li>
            <li><a href="/sound">语音管理</a></li>
            <li class="active"><a href="/service">服务管理</a></li>
            <li class="dropdown">
              <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
                <span class="glyphicon glyphicon-cog" aria-hidden="true"></span> 系统管理
              </a>
              <ul class="dropdown-menu">
                <li><a href="/gateway">中继网关</a></li>
                <li><a href="/status">服务器状态</a></li>
                <li><a href="/logs">日志记录</a></li>
              </ul>
            </li>
          </ul>
          <ul class="nav navbar-nav navbar-right">
            <li><a><img class="img-circle icon" src="/img/<?php echo $user->icon; ?>.png" width="19" height="19"> <?php echo $user->name; ?></a></li>
            <li><a href="/logout"><span class="glyphicon glyphicon-log-out" aria-hidden="true"></span> 退 出</a></li>
          </ul>
        </div>
      </div>
    </nav>
    <div class="container box">
      <div>
        <ol class="breadcrumb">
          <li>当前位置:</li>
          <li>服务管理</li>
          <li class="active">所有服务</li>
          <li class="pull-right" style="margin-right: 12px"><a class="btn btn-default btn-xs" href="/service"><span class="glyphicon glyphicon-repeat"></span> 刷 新</a></li>
        </ol>
      </div>
      <div>
        <table class="table table-condensed table-striped table-hover">
          <thead>
            <tr>
              <th>#</th>
              <th>企业编号</th>
              <th>公司名称</th>
              <th>服务状态</th>
              <th>服务进程PID</th>
              <th>创建时间</th>
              <th>服务操作</th>
            </tr>
          </thead>
          <tbody class="text-muted">
          <?php
          if ($services != null) {
            foreach ($services as $service) {
              echo '<tr>',"\n";
              echo '<td><span class="glyphicon glyphicon-asterisk"></span></td>',"\n";
              echo '<td>',$service['id'],'</td>',"\n";
              echo '<td>',$service['name'],'</td>',"\n";

              if ($service['status']) {
                echo '<td><span class="label label-success">运行中</span></td>',"\n";
              } else {
                echo '<td><span class="label label-default">未启动</span></td>',"\n";
              }
              
              echo '<td>',$service['pid'],'</td>',"\n";
              echo '<td>',$service['create_time'],'</td>',"\n";
              if ($service['status']) {
                echo '<td><a class="btn btn-danger btn-xs" href="/service/stop/',$service['id'],'"><span class="glyphicon glyphicon-unchecked"></span> 停 止</a></td>',"\n";
              } else {
                echo '<td><a class="btn btn-success btn-xs" href="/service/start/',$service['id'],'"><span class="glyphicon glyphicon-expand"></span> 启 动</a></td>',"\n";
              }
              
              echo '</tr>',"\n";
            }
          }
          ?>
          </tbody>
        </table>
      </div>
    </div>
    <script type="text/javascript" src="/js/jquery.min.js"></script>
    <script type="text/javascript" src="/js/bootstrap.min.js"></script>
    <script type="text/javascript">
      $('li.dropdown').mouseover(function() {   
        $(this).addClass('open');
      }).mouseout(function() {
        $(this).removeClass('open');
      });
    </script>
  </body>
</html>
